* Program to replicate results from table 3 of Edge and Rudd,
* "Real-Time Properties of the Federal Reserve's Output Gap"



calendar 1946 1 4
allocate 2010:04



open data table3_data.rat
data(for=rats) / gapaug96 gapnov96 gapjan97 gapmay97 gapaug97 gapnov97 gapjan98  $
                 gapmay98 gapaug98 gapnov98 gapjan99 gapmay99 gapaug99 gapnov99  $
                 gapjan00 gapmay00 gapaug00 gapnov00 gapjan01 gapmay01 gapaug01  $
                 gapoct01 gapjan02 gapmay02 gapaug02 gapoct02 gapjan03 gapapr03  $
                 gapaug03 gapoct03 gapjan04 gapapr04 gapaug04 gapnov04 gapjan05  $
                 gapapr05 gapaug05 gapoct05 gapjan06 gapmay06 gapaug06 gapoct06  $
                 gapjan07 gapoct08 p_pcex p_coreimp nom_coreimp nom_corepce


* gapmmmyy:     Gap measure from month mmm, year yy Greenbook
* p_pcex:       Core PCE, chain price index
* p_coreimp:    Core nonfuel imports, chain price index
* nom_coreimp:  Nominal core nonfuel imports
* nom_corepce:  Nominal core PCE




* Data transformations

set c1pcex_meth = 100.0*(((p_pcex/p_pcex{1})**4.0)-1.0)
set c1pcex_meth 2001:03 2001:03 = c1pcex_meth+0.75
set c1pcex_meth 2001:04 2001:04 = c1pcex_meth-0.75

set c1pmxoil213ng = 100.0*(((p_coreimp/p_coreimp{1})**4.0)-1.0)
set sh_coreimp = 0.5*((nom_coreimp{1}/nom_corepce{1})+(nom_coreimp{2}/nom_corepce{2}))
set sw_coreimp_pcex = sh_coreimp*(c1pmxoil213ng-c1pcex_meth{1})




* Put real-time gap series and corresponding estimation ending dates into arrays

declare vector[series] gapmeas(43)
declare vector[integer] estend_date(43)

set     gapmeas(1)       = gapaug96
compute estend_date(1)   = 1996:02

set     gapmeas(2)       = gapnov96
compute estend_date(2)   = 1996:03

set     gapmeas(3)       = gapjan97
compute estend_date(3)   = 1996:04

set     gapmeas(4)       = gapmay97
compute estend_date(4)   = 1997:01

set     gapmeas(5)      = gapaug97
compute estend_date(5)  = 1997:02

set     gapmeas(6)      = gapnov97
compute estend_date(6)  = 1997:03

set     gapmeas(7)      = gapjan98
compute estend_date(7)  = 1997:04

set     gapmeas(8)      = gapmay98
compute estend_date(8)  = 1998:01

set     gapmeas(9)      = gapaug98
compute estend_date(9)  = 1998:02

set     gapmeas(10)      = gapnov98
compute estend_date(10)  = 1998:03

set     gapmeas(11)      = gapjan99
compute estend_date(11)  = 1998:04

set     gapmeas(12)      = gapmay99
compute estend_date(12)  = 1999:01

set     gapmeas(13)      = gapaug99
compute estend_date(13)  = 1999:02

set     gapmeas(14)      = gapnov99
compute estend_date(14)  = 1999:03

set     gapmeas(15)      = gapjan00
compute estend_date(15)  = 1999:04

set     gapmeas(16)      = gapmay00
compute estend_date(16)  = 2000:01

set     gapmeas(17)      = gapaug00
compute estend_date(17)  = 2000:02

set     gapmeas(18)      = gapnov00
compute estend_date(18)  = 2000:03

set     gapmeas(19)      = gapjan01
compute estend_date(19)  = 2000:04

set     gapmeas(20)      = gapmay01
compute estend_date(20)  = 2001:01

set     gapmeas(21)      = gapaug01
compute estend_date(21)  = 2001:02

set     gapmeas(22)      = gapoct01
compute estend_date(22)  = 2001:03

set     gapmeas(23)      = gapjan02
compute estend_date(23)  = 2001:04

set     gapmeas(24)      = gapmay02
compute estend_date(24)  = 2002:01

set     gapmeas(25)      = gapaug02
compute estend_date(25)  = 2002:02

set     gapmeas(26)      = gapoct02
compute estend_date(26)  = 2002:03

set     gapmeas(27)      = gapjan03
compute estend_date(27)  = 2002:04

set     gapmeas(28)      = gapapr03
compute estend_date(28)  = 2003:01

set     gapmeas(29)      = gapaug03
compute estend_date(29)  = 2003:02

set     gapmeas(30)      = gapoct03
compute estend_date(30)  = 2003:03

set     gapmeas(31)      = gapjan04
compute estend_date(31)  = 2003:04

set     gapmeas(32)      = gapapr04
compute estend_date(32)  = 2004:01

set     gapmeas(33)      = gapaug04
compute estend_date(33)  = 2004:02

set     gapmeas(34)      = gapnov04
compute estend_date(34)  = 2004:03

set     gapmeas(35)      = gapjan05
compute estend_date(35)  = 2004:04

set     gapmeas(36)      = gapapr05
compute estend_date(36)  = 2005:01

set     gapmeas(37)      = gapaug05
compute estend_date(37)  = 2005:02

set     gapmeas(38)      = gapoct05
compute estend_date(38)  = 2005:03

set     gapmeas(39)      = gapjan06
compute estend_date(39)  = 2005:04

set     gapmeas(40)      = gapmay06
compute estend_date(40)  = 2006:01

set     gapmeas(41)      = gapaug06
compute estend_date(41)  = 2006:02

set     gapmeas(42)      = gapoct06
compute estend_date(42)  = 2006:03

set     gapmeas(43)      = gapjan07
compute estend_date(43)  = 2006:04




* Inflation forecasting models

compute ESTSTART=1975:01
set fullgap = gapoct08

set err_full_2q = %NA
set err_full_4q = %NA
set err_full_6q = %NA
set err_full_4qave = %NA

set err_curr_2q = %NA
set err_curr_4q = %NA
set err_curr_6q = %NA
set err_curr_4qave = %NA

set err_nogap_2q = %NA
set err_nogap_4q = %NA
set err_nogap_6q = %NA
set err_nogap_4qave = %NA

set err_ar6_2q = %NA
set err_ar6_4q = %NA
set err_ar6_6q = %NA
set err_ar6_4qave = %NA

set err_ar6c_2q = %NA
set err_ar6c_4q = %NA
set err_ar6c_6q = %NA
set err_ar6c_4qave = %NA

set full_beta = %NA
set curr_beta = %NA
set sum_ar6 = %NA


frml(identity) sw_eq  sw_coreimp_pcex = sh_coreimp*(c1pmxoil213ng-c1pcex_meth{1})



* ************************************************************************


* Two-quarter-ahead forecasts

disp " "
disp " "
disp " "
disp "Two-quarter-ahead forecasts"
disp " "

smpl * *

do iter=1,43

  set s_full = %NA
  set s_curr = %NA
  set s_nogap = %NA
  set s_ar6 = %NA
  set s_ar6c = %NA

  set currgap = gapmeas(iter)
  compute ESTEND = estend_date(iter)

  linreg(noprint) c1pcex_meth ESTSTART ESTEND
  # constant c1pcex_meth{1 to 6} fullgap sw_coreimp_pcex{0 to 1}
  restrict(create,noprint,frml=fulleq) 1
  # 2 3 4 5 6 7
  # 1. 1. 1. 1. 1. 1. 1.

  set full_beta iter iter = %beta(8)


  linreg(noprint) c1pcex_meth ESTSTART ESTEND
  # constant c1pcex_meth{1 to 6} currgap sw_coreimp_pcex{0 to 1}
  restrict(create,noprint,frml=curreq) 1
  # 2 3 4 5 6 7
  # 1. 1. 1. 1. 1. 1. 1.

  set curr_beta iter iter = %beta(8)


  linreg(noprint) c1pcex_meth ESTSTART ESTEND
  # constant c1pcex_meth{1 to 6} sw_coreimp_pcex{0 to 1}
  restrict(create,noprint,frml=nogapeq) 1
  # 2 3 4 5 6 7
  # 1. 1. 1. 1. 1. 1. 1.


  linreg(noprint) c1pcex_meth ESTSTART ESTEND
  # constant c1pcex_meth{1 to 6}
  restrict(create,noprint,frml=ar6ceq) 1
  # 2 3 4 5 6 7
  # 1. 1. 1. 1. 1. 1. 1.


  linreg(noprint,frml=ar6eq) c1pcex_meth ESTSTART ESTEND
  # constant c1pcex_meth{1 to 6}
  summ(noprint)
  #  c1pcex_meth{1 to 6}

  set sum_ar6 iter iter = %sumlc


  group fullmod  fulleq>>s_full sw_eq
  group currmod  curreq>>s_curr sw_eq
  group nogapmod nogapeq>>s_nogap sw_eq
  group ar6mod   ar6eq>>s_ar6
  group ar6cmod  ar6ceq>>s_ar6c

  smpl ESTEND+1 ESTEND+2

  forecast(model=fullmod)
  forecast(model=currmod)
  forecast(model=nogapmod)
  forecast(model=ar6mod)
  forecast(model=ar6cmod)

  smpl * *

  set err_full_2q iter iter = c1pcex_meth(ESTEND+2)-s_full(ESTEND+2)
  set err_curr_2q iter iter = c1pcex_meth(ESTEND+2)-s_curr(ESTEND+2)
  set err_nogap_2q iter iter = c1pcex_meth(ESTEND+2)-s_nogap(ESTEND+2)
  set err_ar6_2q iter iter = c1pcex_meth(ESTEND+2)-s_ar6(ESTEND+2)
  set err_ar6c_2q iter iter = c1pcex_meth(ESTEND+2)-s_ar6c(ESTEND+2)

  set s_full = %NA
  set s_curr = %NA
  set s_nogap = %NA
  set s_ar6 = %NA
  set s_ar6c = %NA


end do iter



* Compute mean errors and RMSEs for the various model forecasts


* Real-time gap model

set temp = %NA
set temp = err_curr_2q**2.0

statistics(noprint) err_curr_2q
disp " "
disp "Errors from model using real-time gap, six-lag model"
* disp "Mean    = " %mean
* disp "St dev. = " sqrt(%variance)
statistics(noprint) temp
disp "RMSE    = " *.## sqrt(%mean) "   N = " * %nobs
disp " "



* Final gap model

set temp = %NA
set temp = err_full_2q**2.0

statistics(noprint) err_full_2q
disp " "
disp "Errors from model using final gap, six-lag model"
* disp "Mean    = " %mean
* disp "St dev. = " sqrt(%variance)
statistics(noprint) temp
disp "RMSE    = " *.## sqrt(%mean) "   N = " * %nobs
disp " "



* Model with no gap

set temp = %NA
set temp = err_nogap_2q**2.0

statistics(noprint) err_nogap_2q
disp " "
disp "Errors from model with no gap at all (six lags)"
* disp "Mean    = " %mean
* disp "St dev. = " sqrt(%variance)
statistics(noprint) temp
disp "RMSE    = " *.## sqrt(%mean) "   N = " * %nobs
disp " "



* Constrained AR(6) model

set temp = %NA
set temp = err_ar6c_2q**2.0

statistics(noprint) err_ar6c_2q
disp " "
disp "Errors from constrained AR(6) model"
* disp "Mean    = " %mean
* disp "St dev. = " sqrt(%variance)
statistics(noprint) temp
disp "RMSE    = " *.## sqrt(%mean) "   N = " * %nobs
disp " "



* Unconstrained AR(6) model

set temp = %NA
set temp = err_ar6_2q**2.0

statistics(noprint) err_ar6_2q
disp " "
disp "Errors from unconstrained AR(6) model"
* disp "Mean    = " %mean
* disp "St dev. = " sqrt(%variance)
statistics(noprint) temp
disp "RMSE    = " *.## sqrt(%mean) "   N = " * %nobs
disp " "






* ************************************************************************


* Four-quarter-ahead forecasts

disp " "
disp " "
disp " "
disp "Four-quarter-ahead forecasts"
disp " "

smpl * *

do iter=1,43

  set s_full = %NA
  set s_curr = %NA
  set s_nogap = %NA
  set s_ar6 = %NA
  set s_ar6c = %NA

  set currgap = gapmeas(iter)
  compute ESTEND = estend_date(iter)

  linreg(noprint) c1pcex_meth ESTSTART ESTEND
  # constant c1pcex_meth{1 to 6} fullgap sw_coreimp_pcex{0 to 1}
  restrict(create,noprint,frml=fulleq) 1
  # 2 3 4 5 6 7
  # 1. 1. 1. 1. 1. 1. 1.


  linreg(noprint) c1pcex_meth ESTSTART ESTEND
  # constant c1pcex_meth{1 to 6} currgap sw_coreimp_pcex{0 to 1}
  restrict(create,noprint,frml=curreq) 1
  # 2 3 4 5 6 7
  # 1. 1. 1. 1. 1. 1. 1.


  linreg(noprint) c1pcex_meth ESTSTART ESTEND
  # constant c1pcex_meth{1 to 6} sw_coreimp_pcex{0 to 1}
  restrict(create,noprint,frml=nogapeq) 1
  # 2 3 4 5 6 7
  # 1. 1. 1. 1. 1. 1. 1.


  linreg(noprint) c1pcex_meth ESTSTART ESTEND
  # constant c1pcex_meth{1 to 6}
  restrict(create,noprint,frml=ar6ceq) 1
  # 2 3 4 5 6 7
  # 1. 1. 1. 1. 1. 1. 1.


  linreg(noprint,frml=ar6eq) c1pcex_meth ESTSTART ESTEND
  # constant c1pcex_meth{1 to 6}


  group fullmod  fulleq>>s_full sw_eq
  group currmod  curreq>>s_curr sw_eq
  group nogapmod nogapeq>>s_nogap sw_eq
  group ar6mod   ar6eq>>s_ar6
  group ar6cmod  ar6ceq>>s_ar6c

  smpl ESTEND+1 ESTEND+4

  forecast(model=fullmod)
  forecast(model=currmod)
  forecast(model=nogapmod)
  forecast(model=ar6mod)
  forecast(model=ar6cmod)

  smpl * *

  set err_full_4q iter iter = c1pcex_meth(ESTEND+4)-s_full(ESTEND+4)
  set err_curr_4q iter iter = c1pcex_meth(ESTEND+4)-s_curr(ESTEND+4)
  set err_nogap_4q iter iter = c1pcex_meth(ESTEND+4)-s_nogap(ESTEND+4)
  set err_ar6_4q iter iter = c1pcex_meth(ESTEND+4)-s_ar6(ESTEND+4)
  set err_ar6c_4q iter iter = c1pcex_meth(ESTEND+4)-s_ar6c(ESTEND+4)

  set s_full = %NA
  set s_curr = %NA
  set s_nogap = %NA
  set s_ar6 = %NA
  set s_ar6c = %NA


end do iter



* Compute mean errors and RMSEs for the various model forecasts


* Real-time gap model

set temp = %NA
set temp = err_curr_4q**2.0

statistics(noprint) err_curr_4q
disp " "
disp "Errors from model using real-time gap, six-lag model"
* disp "Mean    = " %mean
* disp "St dev. = " sqrt(%variance)
statistics(noprint) temp
disp "RMSE    = " *.## sqrt(%mean) "   N = " * %nobs
disp " "



* Final gap model

set temp = %NA
set temp = err_full_4q**2.0

statistics(noprint) err_full_4q
disp " "
disp "Errors from model using final gap, six-lag model"
* disp "Mean    = " %mean
* disp "St dev. = " sqrt(%variance)
statistics(noprint) temp
disp "RMSE    = " *.## sqrt(%mean) "   N = " * %nobs
disp " "



* Model with no gap

set temp = %NA
set temp = err_nogap_4q**2.0

statistics(noprint) err_nogap_4q
disp " "
disp "Errors from model with no gap at all (six lags)"
* disp "Mean    = " %mean
* disp "St dev. = " sqrt(%variance)
statistics(noprint) temp
disp "RMSE    = " *.## sqrt(%mean) "   N = " * %nobs
disp " "



* Constrained AR(6) model

set temp = %NA
set temp = err_ar6c_4q**2.0

statistics(noprint) err_ar6c_4q
disp " "
disp "Errors from constrained AR(6) model"
* disp "Mean    = " %mean
* disp "St dev. = " sqrt(%variance)
statistics(noprint) temp
disp "RMSE    = " *.## sqrt(%mean) "   N = " * %nobs
disp " "



* Unconstrained AR(6) model

set temp = %NA
set temp = err_ar6_4q**2.0

statistics(noprint) err_ar6_4q
disp " "
disp "Errors from unconstrained AR(6) model"
* disp "Mean    = " %mean
* disp "St dev. = " sqrt(%variance)
statistics(noprint) temp
disp "RMSE    = " *.## sqrt(%mean) "   N = " * %nobs
disp " "






* ************************************************************************


* Forecasts of average inflation over the next four quarters

disp " "
disp " "
disp " "
disp "Forecasts of average over next four quarters"
disp " "

smpl * *

do iter=1,43

  set s_full = %NA
  set s_curr = %NA
  set s_nogap = %NA
  set s_ar6 = %NA
  set s_ar6c = %NA

  set currgap = gapmeas(iter)
  compute ESTEND = estend_date(iter)

  linreg(noprint) c1pcex_meth ESTSTART ESTEND
  # constant c1pcex_meth{1 to 6} fullgap sw_coreimp_pcex{0 to 1}
  restrict(create,noprint,frml=fulleq) 1
  # 2 3 4 5 6 7
  # 1. 1. 1. 1. 1. 1. 1.


  linreg(noprint) c1pcex_meth ESTSTART ESTEND
  # constant c1pcex_meth{1 to 6} currgap sw_coreimp_pcex{0 to 1}
  restrict(create,noprint,frml=curreq) 1
  # 2 3 4 5 6 7
  # 1. 1. 1. 1. 1. 1. 1.


  linreg(noprint) c1pcex_meth ESTSTART ESTEND
  # constant c1pcex_meth{1 to 6} sw_coreimp_pcex{0 to 1}
  restrict(create,noprint,frml=nogapeq) 1
  # 2 3 4 5 6 7
  # 1. 1. 1. 1. 1. 1. 1.


  linreg(noprint) c1pcex_meth ESTSTART ESTEND
  # constant c1pcex_meth{1 to 6}
  restrict(create,noprint,frml=ar6ceq) 1
  # 2 3 4 5 6 7
  # 1. 1. 1. 1. 1. 1. 1.


  linreg(noprint,frml=ar6eq) c1pcex_meth ESTSTART ESTEND
  # constant c1pcex_meth{1 to 6}


  group fullmod  fulleq>>s_full sw_eq
  group currmod  curreq>>s_curr sw_eq
  group nogapmod nogapeq>>s_nogap sw_eq
  group ar6mod   ar6eq>>s_ar6
  group ar6cmod  ar6ceq>>s_ar6c

  smpl ESTEND+1 ESTEND+4

  forecast(model=fullmod)
  forecast(model=currmod)
  forecast(model=nogapmod)
  forecast(model=ar6mod)
  forecast(model=ar6cmod)

  smpl * *

  compute p_4q_ave = 0.25*(c1pcex_meth(ESTEND+1)+c1pcex_meth(ESTEND+2)+c1pcex_meth(ESTEND+3)+c1pcex_meth(ESTEND+4))

  set err_full_4qave iter iter =  p_4q_ave-(0.25*(s_full(ESTEND+1)+s_full(ESTEND+2)+s_full(ESTEND+3)+s_full(ESTEND+4)))
  set err_curr_4qave iter iter =  p_4q_ave-(0.25*(s_curr(ESTEND+1)+s_curr(ESTEND+2)+s_curr(ESTEND+3)+s_curr(ESTEND+4)))
  set err_nogap_4qave iter iter = p_4q_ave-(0.25*(s_nogap(ESTEND+1)+s_nogap(ESTEND+2)+s_nogap(ESTEND+3)+s_nogap(ESTEND+4)))
  set err_ar6_4qave iter iter =   p_4q_ave-(0.25*(s_ar6(ESTEND+1)+s_ar6(ESTEND+2)+s_ar6(ESTEND+3)+s_ar6(ESTEND+4)))
  set err_ar6c_4qave iter iter =   p_4q_ave-(0.25*(s_ar6c(ESTEND+1)+s_ar6c(ESTEND+2)+s_ar6c(ESTEND+3)+s_ar6c(ESTEND+4)))

  set s_full = %NA
  set s_curr = %NA
  set s_nogap = %NA
  set s_ar6 = %NA
  set s_ar6c = %NA

end do iter



* Compute mean errors and RMSEs for the various model forecasts


* Real-time gap model

set temp = %NA
set temp = err_curr_4qave**2.0

statistics(noprint) err_curr_4qave
disp " "
disp "Errors from model using real-time gap, six-lag model"
* disp "Mean    = " %mean
* disp "St dev. = " sqrt(%variance)
statistics(noprint) temp
disp "RMSE    = " *.## sqrt(%mean) "   N = " * %nobs
disp " "



* Final gap model

set temp = %NA
set temp = err_full_4qave**2.0

statistics(noprint) err_full_4qave
disp " "
disp "Errors from model using final gap, six-lag model"
* disp "Mean    = " %mean
* disp "St dev. = " sqrt(%variance)
statistics(noprint) temp
disp "RMSE    = " *.## sqrt(%mean) "   N = " * %nobs
disp " "



* Model with no gap

set temp = %NA
set temp = err_nogap_4qave**2.0

statistics(noprint) err_nogap_4qave
disp " "
disp "Errors from model with no gap at all, six-lag model"
* disp "Mean    = " %mean
* disp "St dev. = " sqrt(%variance)
statistics(noprint) temp
disp "RMSE    = " *.## sqrt(%mean) "   N = " * %nobs
disp " "



* Constrained AR(6) model

set temp = %NA
set temp = err_ar6c_4qave**2.0

statistics(noprint) err_ar6c_4qave
disp " "
disp "Errors from constrained AR(6) model"
* disp "Mean    = " %mean
* disp "St dev. = " sqrt(%variance)
statistics(noprint) temp
disp "RMSE    = " *.## sqrt(%mean) "   N = " * %nobs
disp " "



* Unconstrained AR(6) model

set temp = %NA
set temp = err_ar6_4qave**2.0

statistics(noprint) err_ar6_4qave
disp " "
disp "Errors from unconstrained AR(6) model"
* disp "Mean    = " %mean
* disp "St dev. = " sqrt(%variance)
statistics(noprint) temp
disp "RMSE    = " *.## sqrt(%mean) "   N = " * %nobs
disp " "






* ************************************************************************


* Six-quarter-ahead forecasts

disp " "
disp " "
disp " "
disp "Six-quarter-ahead forecasts"
disp " "

smpl * *

do iter=1,43

  set s_full = %NA
  set s_curr = %NA
  set s_nogap = %NA
  set s_ar6 = %NA
  set s_ar6c = %NA

  set currgap = gapmeas(iter)
  compute ESTEND = estend_date(iter)

  linreg(noprint) c1pcex_meth ESTSTART ESTEND
  # constant c1pcex_meth{1 to 6} fullgap sw_coreimp_pcex{0 to 1}
  restrict(create,noprint,frml=fulleq) 1
  # 2 3 4 5 6 7
  # 1. 1. 1. 1. 1. 1. 1.


  linreg(noprint) c1pcex_meth ESTSTART ESTEND
  # constant c1pcex_meth{1 to 6} currgap sw_coreimp_pcex{0 to 1}
  restrict(create,noprint,frml=curreq) 1
  # 2 3 4 5 6 7
  # 1. 1. 1. 1. 1. 1. 1.


  linreg(noprint) c1pcex_meth ESTSTART ESTEND
  # constant c1pcex_meth{1 to 6} sw_coreimp_pcex{0 to 1}
  restrict(create,noprint,frml=nogapeq) 1
  # 2 3 4 5 6 7
  # 1. 1. 1. 1. 1. 1. 1.


  linreg(noprint) c1pcex_meth ESTSTART ESTEND
  # constant c1pcex_meth{1 to 6}
  restrict(create,noprint,frml=ar6ceq) 1
  # 2 3 4 5 6 7
  # 1. 1. 1. 1. 1. 1. 1.


  linreg(noprint,frml=ar6eq) c1pcex_meth ESTSTART ESTEND
  # constant c1pcex_meth{1 to 6}


  group fullmod  fulleq>>s_full sw_eq
  group currmod  curreq>>s_curr sw_eq
  group nogapmod nogapeq>>s_nogap sw_eq
  group ar6mod   ar6eq>>s_ar6
  group ar6cmod  ar6ceq>>s_ar6c

  smpl ESTEND+1 ESTEND+6

  forecast(model=fullmod)
  forecast(model=currmod)
  forecast(model=nogapmod)
  forecast(model=ar6mod)
  forecast(model=ar6cmod)

  smpl * *

  set err_full_6q iter iter = c1pcex_meth(ESTEND+6)-s_full(ESTEND+6)
  set err_curr_6q iter iter = c1pcex_meth(ESTEND+6)-s_curr(ESTEND+6)
  set err_nogap_6q iter iter = c1pcex_meth(ESTEND+6)-s_nogap(ESTEND+6)
  set err_ar6_6q iter iter = c1pcex_meth(ESTEND+6)-s_ar6(ESTEND+6)
  set err_ar6c_6q iter iter = c1pcex_meth(ESTEND+6)-s_ar6c(ESTEND+6)

  set s_full = %NA
  set s_curr = %NA
  set s_nogap = %NA
  set s_ar6 = %NA
  set s_ar6c = %NA


end do iter



* Compute mean errors and RMSEs for the various model forecasts


* Real-time gap model

set temp = %NA
set temp = err_curr_6q**2.0

statistics(noprint) err_curr_6q
disp " "
disp "Errors from model using real-time gap, six-lag model"
* disp "Mean    = " %mean
* disp "St dev. = " sqrt(%variance)
statistics(noprint) temp
disp "RMSE    = " *.## sqrt(%mean) "   N = " * %nobs
disp " "



* Final gap model

set temp = %NA
set temp = err_full_6q**2.0

statistics(noprint) err_full_6q
disp " "
disp "Errors from model using final gap, six-lag model"
* disp "Mean    = " %mean
* disp "St dev. = " sqrt(%variance)
statistics(noprint) temp
disp "RMSE    = " *.## sqrt(%mean) "   N = " * %nobs
disp " "



* Model with no gap

set temp = %NA
set temp = err_nogap_6q**2.0

statistics(noprint) err_nogap_6q
disp " "
disp "Errors from model with no gap at all (six lags)"
* disp "Mean    = " %mean
* disp "St dev. = " sqrt(%variance)
statistics(noprint) temp
disp "RMSE    = " *.## sqrt(%mean) "   N = " * %nobs
disp " "



* Constrained AR(6) model

set temp = %NA
set temp = err_ar6c_6q**2.0

statistics(noprint) err_ar6c_6q
disp " "
disp "Errors from constrained AR(6) model"
* disp "Mean    = " %mean
* disp "St dev. = " sqrt(%variance)
statistics(noprint) temp
disp "RMSE    = " *.## sqrt(%mean) "   N = " * %nobs
disp " "



* Unconstrained AR(6) model

set temp = %NA
set temp = err_ar6_6q**2.0

statistics(noprint) err_ar6_6q
disp " "
disp "Errors from unconstrained AR(6) model"
* disp "Mean    = " %mean
* disp "St dev. = " sqrt(%variance)
statistics(noprint) temp
disp "RMSE    = " *.## sqrt(%mean) "   N = " * %nobs
disp " "







* ************************************************************************


* Full sample regression (for reference), six inflation lags

disp " "; disp " "; disp " "; disp " "
* disp "Full sample regression (for reference)"; disp " "

linreg(noprint) c1pcex_meth 1975:01 2006:04
# constant c1pcex_meth{1 to 6} gapoct08 sw_coreimp_pcex{0 to 1}
summ(noprint)
# c1pcex_meth{1 to 6}
restrict(create,noprint) 1
# 2 3 4 5 6 7
# 1. 1. 1. 1. 1. 1. 1.
summ(noprint)
# c1pcex_meth{1 to 6}

disp "R-squared, full model = " %rsquared

set fullsamp_beta = %beta(8)

summarize(noprint)
# sw_coreimp_pcex{0 to 1}


* disp " "; disp " "
* disp "Full-sample regression without gap (for reference), six inflation lags"; disp " "

linreg(noprint) c1pcex_meth 1975:01 2006:04
# constant c1pcex_meth{1 to 6} sw_coreimp_pcex{0 to 1}
summ(noprint)
# c1pcex_meth{1 to 6}
restrict(create,noprint) 1
# 2 3 4 5 6 7
# 1. 1. 1. 1. 1. 1. 1.
summ(noprint)
# c1pcex_meth{1 to 6}
summarize(noprint)
# sw_coreimp_pcex{0 to 1}

disp "R-squared, model without gap term = " %rsquared



* Tabulate sum of lag coefficients from rolling estimates of unrestricted AR model

disp " "; disp " "
disp "Tabulated sum of lag coefficients from rolling estimates of unrestricted AR model"; disp " "
statistics(fract) sum_ar6


